<?php

class SildeShowService {
	
	public static function getInstance() {
		return new self();
	}
	
	public function getData($type) {
		$criteria = new CDbCriteria();
		$criteria->condition = "cate='{$type}'";
		$criteria->order = 'sort DESC';
		$criteria->limit = '5';
		return $this->sildeShowData(HotImage::model()->enabled()->findAll($criteria));
	}
	
	public function sildeShowData($data) {
		if(!$data) return array();
		$items = array();
		foreach($data as $one) {
			$items[] = array(
				'src' => Yii::app()->img->config('default')->url($one->image),
				'link' => $one->link,
				'target' => $one->open_type,
				'title' => $one->name,
				'thumb' => Yii::app()->img->config('default')->url($one->thumb),
				'desc' => $one->desc,
			);
		}
		return $items;
	}
	
}

?>